<template>
	<view>
		<detail v-if="pluginReadly" :params="paramString"></detail>
	</view>	
</template>

<script>

	import Cache from '../../../utils/cache';
	import { CITY_INFO} from '../../../config/cache.js'
	 var util = require('@/common/js/util.js');
	 var _getDiffDate = util.getDiffDate;
	 var _addDay = util.addDay;
	 var _dateDiff = util.dateDiff;
	 var _parseDate = util.parseDate;
	 var _formatDate = util.formatDate
	 import { searchLineFt, getGaodeGuihua } from '@/api/bus.js'
	 import emptyPage from '@/components/emptyPage.vue'
	export default {
		components: {emptyPage},
		data() {
			return {
				keyword:'',
				resultList:[],
				type: 1,
				searchFrom:{},
				searchLineList: [],
				loading: true,
				paramString: '',
				pluginReadly: false
				
			}
		},
		onLoad(option) {
			console.log('434',option)
			var city = Cache.has(CITY_INFO)? JSON.parse(Cache.get(CITY_INFO)) : ""
			this.searchFrom = {
				city_id: city.id,
				from_lng:　option.from_lng,
				from_lat:　option.from_lat,
				to_lng:　option.to_lng,
				to_lat:　option.to_lat
			}
			
			let params = {
			      'slon': option.from_lng,          
			      'slat': option.from_lat,           
			      'lon': option.to_lng,             
			      'lat': option.to_lat,            
			      'name': option.name,
				  'addr': option.addr,
				  'type': "bus"			  
			                  
			 };
			 my.loadPlugin({
			  plugin: "2021001157652552@*",
			  success:(res)=>{
			 	 this.pluginReadly = true
			 	  this.paramString = JSON.stringify(params)
			 	 }
			    })
		},
		onReady() {
			// this.initSearch(this.searchFrom)
			
		},
		methods:{
			initSearch(data){
				uni.showLoading({
					title:'正在搜索中...'
				})
				this.loading = true
				getGaodeGuihua(data).then(res => {
					this.loading = false
					uni.hideLoading()
					
					// this.searchLineList = res.data	
					if(res.data){
						this.praseData(res.data.transits)
					}
					
							
			    }).catch(err =>{
					this.loading = false
					uni.hideLoading()
					
				})
			},
			praseData(transits){
				transits.forEach(el => {
					
				})
			},
			goHome(){
				uni.redirectTo({
					url:'/pages/bus/index/index'
				})
				// uni.navigateTo({
				// 	url:'/pages/scenic/trip_list'
				// })
			},
			goRegulatList:function(line_id){
				var date =  _formatDate("yyyy-MM-dd")
				// uni.navigateTo({
				// 	url:'/pages/bus/regular_list/index?line_id='+line_id+'&date='+date
				// })
				uni.navigateTo({
					url:'/pages/bus/line_info/index?line_id='+line_id
				})
				
			},
			goDz(){
				uni.navigateTo({
					url:"/pages/bus/ogz_line/index"
				})
			},
			goAllLine(){
				uni.navigateTo({
					url:"/pages/bus/all_line/index"
				})
			}
		}
		
	}
</script>

<style lang="scss" scoped>
	.list-title{
		margin: 24upx 24upx;
		color: #007aff;
		font-weight: 700;
	}
	.list-main{
		position: relative;
		margin: 24upx 24upx;
		background-color: #fff;
	}
	.line-sn {
		font-size: 15px;
		font-weight: 600;
		color: #000000;
		margin: 8px 10px;
	}
	.od-item{
		color: #888;
		font-size: 12px;
	}
	
	.ticket-item {
		margin-left: auto;
		margin-right: 20px;
	}
	.item-block{
		position: relative;
		padding: 24upx 20upx 24upx 20upx;
		border-radius: 10upx;
		box-shadow: 0 3px 10px 0 rgba(0,0,0,.08);
	}
	.base-info{
		margin:15upx 0;
		padding: 0 6px
	}
	.price{
		font-size: 40upx;
		font-weight: 500;
		color: #333;
	}
    .bot-item{
	  padding: 14upx 0upx 0 0;
	}
	.bule-cle{
		width: 116upx;
		border-radius: 5px;
		border: 1px solid #26a2ff;
		display: flex;
		-webkit-box-align: center;
		align-items: center;
		-webkit-box-pack: center;
		justify-content: center;
		padding: 10upx;
		margin-left: 24upx;
	}
	.time-text {
		color: #333;
		font-size: 24upx;
		margin-bottom: 24upx;
	}
	
	.search-empty{
		position: absolute;
		top: 200px;
		bottom: 0;
		left: 0;
		right: 0;
		display: flex;
		flex-direction: column;
		justify-content: center;
	}

</style>